package com.ruoyi.cfuser.system.controller;

import com.ruoyi.cfuser.cfuser.service.ICfUserService;
import com.ruoyi.cfuser.system.service.SysCfUserService;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.sms.utils.SendSMS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;

@RestController
@RequestMapping
public class SysCfUserController {

    @Autowired
    SysCfUserService sysCfUserService;

    @Autowired
    ICfUserService cfUserService;

    @Autowired
    SendSMS sendSMS;

    @Autowired
    RedisService redisService;

    @PostMapping("/login")
    public AjaxResult login(@RequestBody Map<String, Object> data) {
        String mobile = data.get("mobile").toString();
        String verifyCode = data.get("verifyCode").toString();
        String verifyCodeToken = data.get("verifyCodeToken").toString();
        return sysCfUserService.login(mobile, verifyCode, verifyCodeToken);
    }

    @GetMapping("/getCode")
    public AjaxResult getCode() throws Exception {
        return AjaxResult.success(sendSMS.send());
    }
}
